//
//  InquiryMain_Title_view_WX.m
//  ZITHER
//
//  Created by weixin on 2019/3/13.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "InquiryMain_Title_view_WX.h"
#import "MainAntistopVC_V4.h"
#import "Seach_FittrateSeting_VC_WX.h"
#import "CustomCameraVC.h"

@interface InquiryMain_Title_view_WX ()

@property (nonatomic,strong)BaseBtn *btn2;//寻表

@property (nonatomic,strong)BaseBtn *btnIdentify;//识别

@property (nonatomic,strong)QMUILabel *leb;//热门二手价格

@end

@implementation InquiryMain_Title_view_WX

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
        [self masonry];
    }
    return self;
}


-(void)setUI{
    
    /* MARK: ================= 返回按钮 =================*/
    
    [self addSubview:self.leb];
    
    [self addSubview:self.btn2];
    
    [self addSubview:self.btn3];
    if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]) {
        [self addSubview:self.btnIdentify];
    }
}


-(void)masonry{
    
    [self.btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]) {
        make.right.equalTo(self).offset(-45);
        }else{
            make.right.equalTo(self).offset(-15);
        }
        make.top.equalTo(self).offset(0);
        make.height.mas_equalTo(30);
    }];
    
    if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]) {
        [self.btnIdentify mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.btn2).offset(0);
            make.right.equalTo(self).offset(-15);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(20);
        }];
    }
    
    [self.leb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(15);
        make.height.mas_equalTo(15);
        make.top.equalTo(self.btn2.mas_bottom).offset(20);
        make.bottom.equalTo(self.mas_bottom).offset(-15);
    }];
    
    [self.btn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.centerY.equalTo(self.leb.mas_centerY).offset(0);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(70);

//        make.bottom.equalTo(self.mas_bottom).offset(-17);
        //        make.height.width.mas_equalTo(20);
    }];
    

    
}


-(BaseBtn *)btn3
{
    if (!_btn3) {
        //排序按钮
        _btn3 = [[BaseBtn alloc]initWithFrame:CGRectMake(kScreenW-100, kStatusBarHeight,100, 50)];
//        _btn3.backgroundColor = [UIColor redColor];
        [_btn3 setTitle:@" 最多货源 " forState:UIControlStateNormal];
        [_btn3 setTitle:@" 最多货源 " forState:UIControlStateSelected];
        [_btn3 setTitleColor:baseColorTheme forState:UIControlStateNormal];
        [_btn3 setTitleColor:baseColorTheme forState:UIControlStateSelected];
        [_btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateNormal];
        [_btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateNormal];
        
        _btn3.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14.f];
        _btn3.tag = 300;
        _btn3.imageView.contentMode = UIViewContentModeScaleAspectFit;
        
        [_btn3 sizeToFit];
        
        _btn3.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -20);
        _btn3.imageEdgeInsets = UIEdgeInsetsMake(0, 30, 0, -70);
        
    }
    return _btn3;
}
//nav_btn_ascend nav_btn_descend
-(void)chageBtn{
    
    if (self.btn3.selected) {
        [self.btn3 setTitle:@" 二手价 " forState:UIControlStateNormal];
        [self.btn3 setTitleColor:baseColorTheme forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_ascend"] forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_ascend"] forState:UIControlStateSelected];
        
        //        self.btn3.enabled = NO;
        //        self.trash .backgroundColor = [UIColor redColor];
        //        [self.btn3 mas_remakeConstraints:^(MASConstraintMaker *make) {
        //            make.centerY.equalTo(self.price.mas_centerY).offset(0);
        //            make.right.equalTo(self).offset(-15);
        //            make.width.mas_equalTo(100);
        //            make.height.mas_equalTo(15);
        //        }];
        
    }else{
        [self.btn3 setTitle:@" 二手价 " forState:UIControlStateNormal];
        [self.btn3 setTitleColor:baseColorTheme forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateNormal];
        [self.btn3 setImage:[UIImage imageNamed:@"nav_btn_descend"] forState:UIControlStateSelected];
    }
}


-(BaseBtn *)btn2{
    if (!_btn2) {
        _btn2 = [[BaseBtn alloc]initWithFrame:CGRectMake(20,kStatusBarHeight+80, kScreenW-100, 35)];
        [_btn2 setTitle:@" 寻表" forState:UIControlStateNormal];
        [_btn2 setTitleColor:HexColor(0x999999) forState:UIControlStateNormal];
        _btn2.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [_btn2 setCornerRadiusWithRadius:6 isMasks:YES];
//        [_btn2 setBorderWithColor:[UIColor blackColor] width:1];
        [_btn2 setImage:[UIImage imageNamed:@"搜索结果_搜索"] forState:UIControlStateNormal];
        _btn2.imageEdgeInsets = UIEdgeInsetsMake(0,10,0,0);
        _btn2.titleEdgeInsets = UIEdgeInsetsMake(0,10,0,0);
        _btn2.backgroundColor = HexColor(0xf5f5f5);
        _btn2.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:13.f];
        
        [[_btn2 addTag]subscribeNext:^(id  _Nullable x) {
            if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]) {
                Seach_FittrateSeting_VC_WX *vc = [[Seach_FittrateSeting_VC_WX alloc]init];
                vc.hidesBottomBarWhenPushed = YES;
                [self.getNav pushViewController:vc animated:YES];
            }else{
                MainAntistopVC_V4 *vc = [[MainAntistopVC_V4 alloc] init];
                vc.hidesBottomBarWhenPushed = YES;
                [self.getNav pushViewController:vc animated:YES];
            }

        }];
    }
    return _btn2;
}

-(QMUILabel *)leb{
    if (!_leb) {
        _leb = [[QMUILabel alloc]initWithFrame:CGRectMake(20,kStatusBarHeight+35, kScreenW-20, 40)];
        if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]) {
            _leb.text = @"热门二手表搜索";
        }else{
            _leb.text = @"热门二手表询价";
        }
        _leb.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14];
        _leb.textColor = [UIColor blackColor];
    }
    return _leb;
}
-(BaseBtn *)btnIdentify{
    if (!_btnIdentify) {
        _btnIdentify = [BaseBtn initCustomBtn:@[@"打卡_扫码"]];
        _btnIdentify.backgroundColor = [UIColor clearColor];
        [[_btnIdentify addTag]subscribeNext:^(id  _Nullable x) {
            CustomCameraVC *vc = [[CustomCameraVC alloc] init];
            vc.hidesBottomBarWhenPushed = YES;
            [self.getNav pushViewController:vc animated:YES];
        }];
    }
    return _btnIdentify;
}
@end

